package org.zlb.netty.client.discard;

import java.io.OutputStream;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.SocketAddress;

public class DiscardClient {

    public static void main(String[] args) {
        try (Socket socket = new Socket()){
            SocketAddress endpoint = new InetSocketAddress("127.0.0.1", 8080);
            socket.setKeepAlive(true);
            socket.connect(endpoint);
            
            OutputStream out = socket.getOutputStream();
            String msg = "这是DiscardClient发送的消息：";
            int total = 0;
            while (true) {
                out.write(msg.getBytes());
                if (total > 10)
                    break;
                total ++;
                out.flush();
            }
            
        } catch (Exception e) {
            System.out.print("服务端异常，关闭连接");
        }
        
    }
}
